package com.longge;

public class SlowestKey {

    public char slowestKey(int[] releaseTimes, String keysPressed) {

        int maxTime = Integer.MIN_VALUE;
        char ans = ' ';
        for (int i = 0; i < releaseTimes.length; i++) {
            int release;
            if (i == 0) {
                release = releaseTimes[i];
            } else {
                release = releaseTimes[i] - releaseTimes[i - 1];
            }
            if (maxTime < release) {
                maxTime = release;
                ans = keysPressed.charAt(i);
            }else if (maxTime==release){
                if (ans==' '){
                    ans = keysPressed.charAt(i);
                }else if (ans<keysPressed.charAt(i)){
                    ans = keysPressed.charAt(i);
                }
            }
        }
        return ans;
    }

}
